home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWEXCDEF_H
- #define FWEXCDEF_H
- //========================================================================================
- //
- // File: FWExcDef.h
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWONSTAC_H
- #include "FWOnStac.h"
- #endif
-
- #if defined(FW_DEBUG) && !defined(FWTRACE_H)
- #include "FWTrace.h"
- #endif
-
- #ifndef FWAUTODE_H
- #include "FWAutoDe.h"
- #endif
-
- #ifndef FWCLAINF_H
- #include "FWClaInf.h"
- #endif
-
- #ifndef FWEXCEPT_H
- #include "FWExcept.h"
- #endif
-
- #ifndef FWTRYBLO_H
- #include "FWTryBlo.h"
- #endif
-
- #ifndef FWEXCRUN_H
- #include "FWExcRun.h"
- #endif
-
- #ifndef FWDELSTA_H
- #include "FWDelSta.h"
- #endif
-
- #if !defined(FWEXCLOG_H) && defined(FW_DEBUG)
- #include "FWExcLog.h"
- #endif
-
- #if !defined(FWNEWHEL_H) && defined(FW_USE_NEW_HELPER)
- #include "FWNewHel.h"
- #endif
-
- #ifdef FW_BAD_CODE_GENERATION
- int ReturnFalse();
- int ReturnTrue();
- #define FW_BEL_FALSE ::ReturnFalse()
- #define FW_BEL_TRUE ::ReturnTrue()
- #else
- #define FW_BEL_FALSE 0
- #define FW_BEL_TRUE 1
- #endif
-
- //========================================================================================
- // Exception Handling Interface Macros
- //========================================================================================
-
- #define FW_VOLATILE(a) ((void) &a)
- #define FW_DUMMY_RETURN_TRUE return 1;
-
- #ifndef FW_DISABLE_BEL
-
- #ifdef FW_USE_NEW_HELPER
- #define FW_NEW(class, args) (class*) \
- ( \
- new(_FW_CPrivNewHelper(::operator new, ::operator delete)) class##args, \
- (void*) _FW_CPrivNewHelper::PopNewHelper()->ForgetObject() \
- )
- #else
- #define FW_NEW(class, args) new class##args
- #endif
-
- #ifdef FW_DEBUG
- // These two defines are solely to make the code immediately below more readable
- #define FW_SAVE_TRACE_STATE \
- FW_SPrivTraceGlobals& __traceGlobals = FW_CPrivTraceTaskGlobals::GetTraceGlobals(); \
- unsigned short __traceDepth = __traceGlobals.gTraceDepth;
- #define FW_RESTORE_TRACE_STATE \
- __traceGlobals.gTraceDepth = __traceDepth;
- #else
- #define FW_SAVE_TRACE_STATE
- #define FW_RESTORE_TRACE_STATE
- #endif
-
- #define FW_TRY \
- { \
- FW_SPrivExceptionGlobals& __excGlobals = FW_CExceptionTaskGlobals::GetExceptionGlobals(); \
- FW_SAVE_TRACE_STATE \
- jmp_buf __jumpBuffer; \
- if(setjmp(__jumpBuffer) == 0) \
- { \
- _FW_CTryBlockContext __context(__excGlobals, __jumpBuffer);
-
- #define FW_CATCH_BEGIN \
- } \
- else \
- { \
- FW_RESTORE_TRACE_STATE \
- if (FW_BEL_FALSE) \
- {
-
- #define FW_CATCH(class, error) \
- } \
- else if (__excGlobals.gThrownException->__IsKindOf(FW_CLASS_REFERENCE(class))) \
- { \
- class error = * (class*) __excGlobals.gThrownException; \
- _FW_CExceptionRuntime::CaughtException(__excGlobals, &error);
-
- #define FW_CATCH_REFERENCE(class, error) \
- } \
- else if (__excGlobals.gThrownException->__IsKindOf(FW_CLASS_REFERENCE(class))) \
- { \
- class & error = *(class*) __excGlobals.gThrownException; \
- _FW_CExceptionRuntime::CaughtReferenceException(__excGlobals);
-
- #define FW_CATCH_NO_INSTANCE(class) \
- } \
- else if (__excGlobals.gThrownException->__IsKindOf(FW_CLASS_REFERENCE(class))) \
- { \
- _FW_CExceptionRuntime::CaughtNoInstanceException(__excGlobals);
-
- #define FW_CATCH_EVERYTHING() \
- } \
- else if (FW_BEL_TRUE) \
- { \
- _FW_CExceptionRuntime::CaughtEverythingException(__excGlobals);
-
- #define FW_CATCH_END \
- } \
- else \
- { \
- _FW_CExceptionRuntime::KeepThrowing(__excGlobals); \
- } \
- _FW_CExceptionRuntime::CatchCleanup(__excGlobals); \
- } \
- }
-
- #define FW_THROW(error) \
- _FW_CExceptionRuntime::Throw(error)
-
- #define FW_THROW_SAME() \
- _FW_CExceptionRuntime::ThrowSame()
-
- #define FW_THROWS_NOTHING() \
- _FW_SThrowGuard __nothing
-
- #define FW_THROWS(class) \
- _FW_SThrowGuard __nothing##class(FW_CLASS_REFERENCE(class))
-
- #ifdef FW_USE_NEW_HELPER
- #define FW_END_CONSTRUCTOR \
- _FW_CExceptionRuntime::EndConstructor(this, sizeof(*this));
- #define FW_START_DESTRUCTOR \
- if (_FW_PrivIsOnStack(this)) \
- _FW_CDeleteStack::PopIfTopEquals(this);
- #else
- #define FW_END_CONSTRUCTOR \
- if (_FW_PrivIsOnStack(this)) \
- _FW_CDeleteStack::Push(this);
- #define FW_START_DESTRUCTOR \
- if (_FW_PrivIsOnStack(this)) \
- _FW_CDeleteStack::PopIfTopEquals(this);
- #endif
-
-
-
-
- #else
- // This is how to turn exceptions off
-
- #define FW_TRY \
- { \
- if(FW_BEL_TRUE) \
- {
-
- #define FW_CATCH_BEGIN \
- } \
- else \
- { \
- if (FW_BEL_FALSE) \
- {
-
- #define FW_CATCH(class, error) \
- } \
- else if (FW_BEL_FALSE) \
- { \
- class error = * (class*) 0;
-
- #define FW_CATCH_REFERENCE(class, error) \
- } \
- else if (FW_BEL_FALSE) \
- { \
- class & error = *(class*) 0;
-
- #define FW_CATCH_NO_INSTANCE(class) \
- } \
- else if (FW_BEL_FALSE) \
- {
-
- #define FW_CATCH_EVERYTHING() \
- } \
- else if (FW_BEL_TRUE) \
- {
-
- #define FW_CATCH_END \
- } \
- else \
- { \
- } \
- } \
- }
-
- #define FW_THROW(error) FW_DEBUG_MESSAGE(#error)
- #define FW_THROW_SAME()
- #define FW_THROWS_NOTHING()
- #define FW_THROWS(class)
-
- #define FW_END_CONSTRUCTOR
- #define FW_START_DESTRUCTOR
- #define FW_NEW(class, args) new class##args
- #endif
-
- //========================================================================================
- // Exception Logging Macros
- //========================================================================================
-
- #ifdef FW_DEBUG
- #define FW_LOG_OR_TRIGGER_EXCEPTION(class, instance) \
- { \
- FW_SPrivExceptionLog& __logGlobals = _FW_CExceptionLog::GetExceptionLogGlobals(); \
- if (__logGlobals.gLogEnabled) \
- { \
- _FW_CExceptionLog::LogException(FW_CLASS_REFERENCE(class)); \
- } \
- else if ((__logGlobals.gTriggerClass == FW_CLASS_REFERENCE(class)) || __logGlobals.gTriggerPoint)\
- { \
- _FW_CExceptionLog::TriggerException(FW_CLASS_REFERENCE(class), instance); \
- } \
- }
- #define FW_CAUSE_EXCEPTION_BY_NAME(name) _FW_CExceptionLog::CauseException(FW_CLASS_REFERENCE(name));
- #define FW_CAUSE_EXCEPTION_BY_COUNT(count) _FW_CExceptionLog::CauseException(count);
- #else
- #define FW_LOG_OR_TRIGGER_EXCEPTION(class, instance)
- #define FW_CAUSE_EXCEPTION_BY_NAME(name)
- #define FW_CAUSE_EXCEPTION_BY_COUNT(count)
- #endif
-
- //========================================================================================
- // Exception Debugging Macros
- //========================================================================================
-
- #ifdef FW_DEBUG
- #define FW_FWEAK_ON_THROW(class) _FW_CExceptionRuntime::SetBreakOnThrow(FW_CLASS_REFERENCE(class))
- #define FW_NO_FWEAK_ON_THROW _FW_CExceptionRuntime::SetBreakOnThrow(NULL)
- #define FW_EXCEPTION_FWEAK_CONTEXT(class) FW_CExceptionBreakContext __BreakContext(FW_CLASS_REFERENCE(class))
- #else
- #define FW_FWEAK_ON_THROW(class)
- #define FW_NO_FWEAK_ON_THROW
- #define FW_EXCEPTION_FWEAK_CONTEXT(class)
- #endif
-
- #endif
-